<template>
  <div class="components-container">
    <!-- 新增修改 -->
    <sweet-modal ref="dialog" class="dialog" :sweetModalMaxWidth="maxWidth">
      <h3>{{title}}</h3>
      <div>
        <fieldset class="layui-elem-field layui-field-title">
          <legend>基本信息</legend>
        </fieldset>
        <div style="margin:10px 50px;">
          <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">逝者姓名</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="prpData.PRPDEADNAME"></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">逝者年龄</label>
              <div class="layui-input-inline">
                <el-input-number v-model="prpData.PRPDEADAGE" :min="0"></el-input-number>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">逝者性别</label>
              <div class="layui-input-inline">
                <el-select v-model="prpData.PRPDEADSEX" filterable>
                  <el-option v-for="item in sexType" :key="item.CodeValue" :label="item.CodeName" :value="item.CodeValue">
                  </el-option>
                </el-select>
              </div>
            </div>
             <div class="layui-inline">
              <label class="layui-form-label">接尸时间</label>
              <div class="layui-input-inline chooseTime">
                <el-date-picker style="width:115px;float:left;" clear-icon="null" type="date" v-date v-model="prpData.PRPWORKDATE"></el-date-picker>
                <el-time-picker ref="choosetime" style="width:75px;float:left" clear-icon="null" v-date v-model="prpData.PRPWORKTIME" format='HH:mm'></el-time-picker>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">车辆类型</label>
              <div class="layui-input-inline">
                <el-select v-model="cdhcartype" filterable @change="pickupcardata($event)">
                  <el-option v-for="item in carLics" :key="item.value" :label="item.label" :value="item.label">
                  </el-option>
                </el-select>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">接运车辆</label>
              <div class="layui-input-inline" ref="pickupcars">
                <el-select v-model="pickupcar" filterable>
                  <el-option v-for="item in pickupcardatas" :key="item.Value" :label="item.label" :value="item.label">
                  </el-option>
                </el-select>
              </div>
            </div>
          </div>
          
          <div class="layui-form-item">
            <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">接尸地点</label>
              <div class="layui-input-inline">
                <el-select v-model="prpData.PRPADDID" @visible-change="selectAddr">
                  <el-option v-for="item in commonAddr" :key="item.CodeValue" :label="item.CodeName" :value="item.CodeValue"></el-option>
                </el-select>
              </div>
              <div class="layui-input-inline">
                <el-input type="text" v-model=" prpData.PRPCORPSEADDRESS" style="width:570px"></el-input>
              </div>
            </div>
          </div>
            <div class="layui-inline">
              <label class="layui-form-label">业务类别</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="prpData.PRPYITIQXDESC" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">接运类别</label>
              <div class="layui-input-inline">
                <el-select v-model="prpData.PRPFEEDERCATEGORY">
                  <el-option label="不选择" :value="null"></el-option>
                  <el-option v-for="item in feeders" :key="item.value" :label="item.CodeName" :value="item.CodeName">
                  </el-option>
                </el-select>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">处理单位</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="prpData.PRPPROCESSINGUNIT"></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">联系人1</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="prpData.PRPLINKMAN"></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">联系电话</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="prpData.PRPLINKPHONE"></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">来电日期</label>
              <div class="layui-input-inline chooseTime">
                <el-date-picker type="date" v-date v-model="prpData.PRPCALLDATE"></el-date-picker>
              </div>
            </div>
          </div>

          <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">联系人2</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="prpData.PRPSPARELINKMAN"></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">联系电话</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="prpData.PRPSPARELINKPHONE"></el-input>
              </div>
            </div>
             <div class="layui-inline">
              <label class="layui-form-label" >驾驶员</label>
              <div class="layui-input-inline">
                <el-select v-model="prpData.Cdh.CDHDRIVER">
                  <el-option label="不选择" :value="null"></el-option>
                  <el-option v-for="item in drivers" :key="item.value" :label="item.label" :value="item.value">
                  </el-option>
                </el-select>
              </div>
            </div>
          </div>

           <div class="layui-form-item">
           <div class="layui-inline">
              <label class="layui-form-label" >灵堂号</label>
              <div class="layui-input-inline">
                <el-select v-model="prpData.PRPLINID">
                  <el-option label="不选择" :value="null"></el-option>
                  <el-option v-for="item in hallnumber" :key="item.value" :label="item.label" :value="item.value">
                  </el-option>
                </el-select>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">开庭人员</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="prpData.PRPLINMAN"></el-input>
              </div>
            </div>
             <div class="layui-inline">
              <label class="layui-form-label">灵堂预约</label>
              <div class="layui-input-inline chooseTime">
                <el-date-picker style="width:115px;float:left;" clear-icon="null" type="date" v-date v-model="prpData.PRPLINSTRTDATE"></el-date-picker>
                <el-time-picker ref="choosetime" style="width:75px;float:left" clear-icon="null" v-date v-model="prpData.PRPLINSTRTIME" format='HH:mm'></el-time-picker>
              </div>
            </div>
          </div>
        
          <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">备注</label>
              <div class="layui-input-inline">
                <el-input style="width:770px" type="textarea" :autosize="{ minRows: 2, maxRows: 4}" placeholder="请输入内容" v-model="prpData.PRPDESCRIBE">
                </el-input>
              </div>
            </div>
          </div>
          <div class="layui-form-item">
          </div>
        </div>
        <fieldset class="layui-elem-field layui-field-title">
          <legend>服务项目</legend>
        </fieldset>
        <div class="layui-form-item" style="padding-left:130px">
          <el-checkbox-group v-model="checkedItem" @change="ServiceItemsChange">
            <el-checkbox v-for="value in ServiceItemsList" :label="value.SITID" :key="value.SITID" @change="changItem($event,value)">{{value.SITNAME}}</el-checkbox>
          </el-checkbox-group>
        </div>
      </div>
      <div class="layui-form-item btnCenter">
        <el-button @click="closeDialog">取消</el-button>
        <el-button type="primary" :loading="this.$store.state.isloading" @click="submit">提交</el-button>
      </div>
    </sweet-modal>
    <!-- 详情 -->
    <sweet-modal ref="info" class="dialog" :sweetModalMaxWidth="maxWidth">
      <h3>{{title}}</h3>
      <label>业务编号：{{prpData.PRPNO}}</label>
      <fieldset class="layui-elem-field layui-field-title">
        <legend>基本信息</legend>
      </fieldset>
      <div style="margin:10px 50px;">
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">逝者姓名</label>
            <div class="layui-input-inline">
              <el-input type="text" v-model="prpData.PRPDEADNAME" readonly></el-input>
            </div>
          </div>
           <div class="layui-inline">
            <label class="layui-form-label">逝者年龄</label>
            <div class="layui-input-inline">
              <el-input type="text" v-model="prpData.PRPDEADAGE" readonly></el-input>
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">逝者性别</label>
            <div class="layui-input-inline">
              <el-input type="text" v-model="prpData.PRPDEADSEXDESC" readonly></el-input>
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">接尸时间</label>
            <div class="layui-input-inline chooseTime">
              <el-date-picker style="width:115px;float:left;" clear-icon="null" type="date" v-date v-model="prpData.PRPWORKDATE" readonly></el-date-picker>
              <el-time-picker ref="choosetime" style="width:75px;float:left" clear-icon="null" v-date v-model="prpData.PRPWORKTIME" format='HH:mm' readonly></el-time-picker>
            </div>
          </div>
          <div class="layui-inline">
              <label class="layui-form-label">车辆类型</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="cdhcartype" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">接运车辆</label>
              <div class="layui-input-inline" ref="pickupcars">
                <el-input type="text" v-model="pickupcar" readonly></el-input>
              </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">接尸地点</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model=" prpData.PRPCORPSEADDRESS" style="width:770px"></el-input>
              </div>
            </div>
          </div>
           <div class="layui-inline">
              <label class="layui-form-label">业务类别</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="prpData.PRPYITIQXDESC" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">接运类别</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="prpData.PRPFEEDERCATEGORY" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">处理单位</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="prpData.PRPPROCESSINGUNIT" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">联系人1</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="prpData.PRPLINKMAN" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">联系电话</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="prpData.PRPLINKPHONE" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">来电日期</label>
              <div class="layui-input-inline">
                <el-date-picker type="date" placeholder="选择日期" v-model="prpData.PRPCALLDATE" format="yyyy-MM-dd" disabled></el-date-picker>
              </div>
            </div>
          </div>
           <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">联系人2</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="prpData.PRPSPARELINKMAN" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">联系电话</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="prpData.PRPSPARELINKPHONE" readonly></el-input>
              </div>
            </div>
             <div class="layui-inline">
              <label class="layui-form-label" >驾驶员</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="prpData.Cdh.STANAME" readonly></el-input>
              </div>
            </div>
          </div>

           <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">灵堂号</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="prpData.PRPLINNAME" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">开庭人员</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="prpData.PRPLINMAN " readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
            <label class="layui-form-label">灵堂预约</label>
            <div class="layui-input-inline chooseTime">
              <el-date-picker style="width:115px;float:left;" clear-icon="null" type="date" v-date v-model="prpData.PRPLINSTRTDATE" readonly></el-date-picker>
              <el-time-picker ref="choosetime" style="width:75px;float:left" clear-icon="null" v-date v-model="prpData.PRPLINSTRTIME" format='HH:mm' readonly></el-time-picker>
            </div>
          </div>
          </div>
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-inline">
              <el-input style="width:770px" type="textarea" :autosize="{ minRows: 2, maxRows: 4}" placeholder="请输入内容" v-model="prpData.PRPDESCRIBE" readonly>
              </el-input>
            </div>
          </div>
        </div>
      </div>
      <fieldset class="layui-elem-field layui-field-title">
        <legend>服务项目</legend>
      </fieldset>
      <div style="margin:30px 50px;">
        <el-checkbox-group v-model="checkedItem" @change="ServiceItemsChange">
          <el-checkbox v-for="value in ServiceItemsList" :label="value.SITID" :key="value.SITID" disabled>{{value.SITNAME}}</el-checkbox>
        </el-checkbox-group>
      </div>
      <div class="layui-form-item btnCenter">
        <el-button @click="infoClose">取消</el-button>
      </div>
    </sweet-modal>
    <printPdf ref="prints"></printPdf>
  </div>
</template>

<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/common.scss";
.el-button + .el-button {
  margin-left: 0;
}
.longtext {
  width: 480px;
}
.longertext {
  width: 770px;
}
.sweet-btn {
  margin-top: 20px;
}
</style>
<script>
import apiBase from "@/api/apiBase.js";
import sweetModal from "@/components/sweetModal";
import printPdf from "@/components/Pdf/Print";
import { manage } from "@/mixins/managePage.js";
import { formatDate, timeStringToDate } from "@/utils/date.js";
import { PRPORDER, ORDER} from "@/const/orderConst.js";
const onecar = '普通车';
const twocar = '高档车';
const threecar = '自送';
export default {
  mixins: [manage],
  data() {
    return {
      cauinfo: [],
      cause: [],
      REGCAUSA: null,
      REGCAUSASON: null,
      order: null,
      maxWidth: 1100,
      title: null,
      prpWorkDateTime: null,
      prpWorkDateTimeInfo: null,
      addressInfo: null,
      addsInfo: {},
      commonAddr: [],
      wakes:[],
      remains:[],
      feeders:[],
      
      //编码
      carLics: [],
      pickupcardatas:[],
      drivers: [],
      hallnumber: [],
      preSitDesc: null,
      reserveType: [],
      reserveStatus: [],
      serviceListType: [],
      sexType: [],
      ServiceItemsList: [],
      checkedItem: [],
      area: [],
      carryArea: "",
      selectData: {
        TypeEquals: null,
        LinkManLike: null,
        DeadNameLike: null,
        StatusEquals: null
      },
      prpData: {
        PRPID: null,
        PRPNO: null,
        PRPLINKMAN: null,
        PRPDEADAGE: null,
        PRPDEADSEX: null,
        PRPLINKPHONE: null,
        PRPORIGINALCALL: null,
        PRPCALLDATE: null,
        PRPDEADNAME: null,
        PRPYITIQX: null,
        PRPYITIQXDESC: '守灵',
        PRPDESCRIBE: "",
        PRPCORPSEADDRESS: null,
        PRPADDID: "",
        PRPLINID:'',
        PRPMEMID:'',
        PRPFEEDERCATEGORY:'',
        PRPWORKDATE: "",
        // PRPWORKTIMES: null,
        PRPWORKTIME: null,
   
        PRPPROCESSINGUNIT:null,
        PRPSPARELINKMAN:null,
        PRPSPARELINKPHONE:null,
        PRPLINMAN: null,
        PRPLINID: null,
        // PRPFEEDERCATEGORY:'',
        PRPLINSTRTDATE: "",
        PRPLINSTRTIME: null,
        PRPMEMSTRDATE: null,
        PRPMENSTRTIME: null,
       

        //服务项目预约信息
        Psts: [],
        //派车信息
        Cdh: {
          CDHCARID: null,
          CARLIC: null,
          CARCODNAME: null,
          CARCODNAMEDESC: null,
          CDHDRIVER: null,
          STANAME: null
        }
      },
     regDataEexend:{
        leasetime: null,
        appointmenttime: null,
     },
      cdhcar: ["", ""],
      carType: null,
      cdhcartype: null,
      pickupcar:null
    };
  },
  methods: {
    open(order, id) {
      this.order = order;
      this.maxHeight = window.innerHeight - 240;
      //清理数据
      // this.prpData.PRPCALLDATE=new Date();
     
      switch (this.order) {
        case PRPORDER.ADD:
          this.dataRepeat();//数据重置
          this.gethallnumber();
          this.title = "灵堂预约新增";
          this.initSelectData();//初始化下拉框
          this.prpData.PRPWORKDATE = new Date();
          this.prpData.PRPLINSTRTDATE = new Date();
          // this.regDataEexend.leasetime = new Date();
          // this.regDataEexend.appointmenttime = new Date();
          this.$refs.dialog.open();
          break;
        case PRPORDER.MODIFY:
          this.title = "灵堂预约修改";
          this.initSelectData();
          this.dataInfo(id);
          this.$refs.dialog.open();
          break;
        case PRPORDER.INFO:
          this.title = "灵堂预约详情";
          this.initSelectData();
          this.dataInfo(id);
          this.$refs.info.open();
          break;
        default:
      }
    },
    pickupcardata(val){
      switch(val){
        case onecar://普通车
          this.pickupcardatas = this.carLics[0].children;
          if(this.pickupcardatas.length == 0){
            this.pickupcar = null;
          }else{
             this.pickupcar = this.pickupcardatas[0].label;
          }
          break;
        case twocar://高档车
          this.pickupcardatas = this.carLics[1].children;
          if(this.pickupcardatas.length == 0){
            this.pickupcar = null;
          }else{
             this.pickupcar = this.pickupcardatas[0].label;
          }
          break;
        case threecar://自送车
          this.pickupcardatas = this.carLics[2].children;
          if(this.pickupcardatas.length == 0){
            this.pickupcar = null;
          }else{
             this.pickupcar = this.pickupcardatas[0].label;
          }
          break;
        default:
      }
    },

  //获取死亡原因
    getCausa() {
      let data = {};
      apiBase.DoService(data, apiBase.getApiAdress().Code.GetCausa, res => {
        let caudata = res.data.content;
        this.cause = caudata.map(item => ({
          label: item.CAENAME,
          value: item.CAEID,
          children: item.Caus.map(itemCau => ({
            label: itemCau.CAUNAME,
            value: itemCau.CAUID
          }))
        }));
        if (this.cause[0] && this.cause[0].children[0])
          this.cauinfo = [this.cause[0].value, this.cause[0].children[0].value];
      });
    },

    //初始化下拉框数据
    initSelectData() {
      //初始化下拉框数据
      this.getReserveType();
      this.getSexType();
      this.getReserveStatus();
      this.getServiceItems();
      this.getCar();
      this.getCommonAddr();
      this.getCausa();
      this.getServiceTypes();
      this.getDrivers();
      // this.gethallnumber();
      this.getWakes();
      this.getRemains();
      this.getFeeders();
    },
    //提交
    submit() {
      switch (this.order) {
        case PRPORDER.ADD:
          this.dataAdd();
          break;
        case PRPORDER.MODIFY:
          this.dataModify();
          break;
        case PRPORDER.DELETE:
          break;
        case PRPORDER.INFO:
          break;
        default:
      }
    },
    closeDialog() {
      if (this.order === PRPORDER.ADD || this.order === PRPORDER.MODIFY)
        this.$refs.dialog.close();
      else if (this.order === PRPORDER.INFO) this.$refs.info.close();
    },
    //获取预约类型
    getReserveType() {
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Code.GetReserveType,
        res => {
          this.reserveType = res.data.content;
        }
      );
    },
    //获取常用地址
    getCommonAddr() {
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Code.GetCommonAddress,
        res => {
          this.commonAddr = res.data.content;
        }
      );
    },
    //接运类别
    getFeeders(){
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Code.GetFeederCategory,
        res => {
          this.feeders = res.data.content;
        }
      );
    },
    //获取租用守灵
    getWakes(){
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().MourningUse.QueryMourning,
        res => {
          this.wakes = res.data.content;
        }
      );
    },
    //获取遗体告别
    getRemains(){
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().MemorialUse.QueryMemorial,
        res => {
          this.remains = res.data.content;
        }
      );
    },
    //获取性别
    getSexType() {
      let data = {};
      apiBase.DoService(data, apiBase.getApiAdress().Code.GetSex, res => {
        this.sexType = res.data.content;
      });
    },
    //获取预约状态
    getReserveStatus() {
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Reserve.GetReserveStatus,
        res => {
          this.reserveStatus = res.data.content;
        }
      );
    },
    //获取服务类型
    getServiceTypes() {
      let data = {};
      apiBase.DoService(data, apiBase.getApiAdress().Code.GetYitiqx, res => {
        this.serviceListType = res.data.content;
        this.prpData.PRPYITIQX = this.serviceListType[0].CodeValue;
      });
    },
    //获取服务项目
    getServiceItems() {
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Reserve.QueryServiceItem,
        res => {
          let serviceList = res.data.content;
          console.log(26314853);
          console.log(serviceList);
          this.ServiceItemsList = [];
          for (var i in serviceList) {
            this.ServiceItemsList.push.apply(
              this.ServiceItemsList,
              serviceList[i].Sits
            );
          }
          console.log(this.ServiceItemsList);
        }
      );
    },
    //获取车辆信息
    getCar() {
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Car.QueryCarByType,
        res => {
          let cardata = res.data.content;
          let legendsCarData = cardata.map(item => ({
            label: item.CodeName,
            value: item.CodeValue,
            children: item.list_Cars.map(caritem => ({
              label: caritem.CARLIC,
              value: caritem.CARID
            }))
          }));
          this.carLics = legendsCarData;
          if(this.carLics.length >0){
            this.cdhcartype = this.carLics[this.carLics.length - 1].label;//车辆类型
            this.pickupcar = this.carLics[this.carLics.length - 1].children[0].label;//接运车辆
          }else{
            this.cdhcartype = '';
            this.pickupcar = '';
          }
         
          this.pickupcardata(this.pickupcar);
        }
      );
     
      // this.cdhcartype = this.carLics[2].
    },
    //获取司机
    getDrivers() {
      let data = {};
      apiBase.DoService(data, apiBase.getApiAdress().Staff.QueryDriver, res => {
        let driverData = res.data.content,
          legendsDrivers = driverData.map(item => ({
            label: item.STANAME,
            value: item.STAID
          }));
        this.drivers = legendsDrivers;
      });
    },
    // 获取灵堂号
    gethallnumber(){
        let data = {
          LINID: ORDER.PRPLINID
        };
      apiBase.DoService(data, apiBase.getApiAdress().MourningUse.QueryMourning, res => {
          console.log(44455);
          console.log(res);
        let driverData = res.data.content,
          legendsDrivers = driverData.map(item => ({
            label: item.LINNAME,
            value: item.LINID
          }));
        this.hallnumber = legendsDrivers;
      });
    },
    //登记新增
    dataAdd() {
      for(var i in this.pickupcardatas){
        if(this.pickupcardatas[i].label == this.pickupcar){
          this.prpData.Cdh.CDHCARID = this.pickupcardatas[i].value;
        }
      }
      console.log(5000);
      console.log(this.prpData.Cdh.STANAME);
      // this.prpData.Cdh.CDHCARID = this.cdhcar[this.cdhcar.length - 1];
      let Data = JSON.parse(JSON.stringify(this.prpData));
      //  if(Data.PRPLINID == ''){
      //   Data.PRPLINSTRTDATE = '';
      //   Data.PRPLINSTRTIME = '';
      // }else{
      //   Data.PRPLINSTRTDATE = formatDate(this.regDataEexend.leasetime, "yyyyMMdd");
      //   Data.PRPLINSTRTIME = formatDate(this.regDataEexend.leasetime, "hhmmss");
      // }
      // if(Data.PRPMEMID == ''){
      //   Data.PRPMEMSTRDATE = '';
      //   Data.PRPMENSTRTIME = '';
      // }else{
      //   Data.PRPMEMSTRDATE = formatDate(this.regDataEexend.appointmenttime, "yyyyMMdd");
      //   Data.PRPMENSTRTIME = formatDate(this.regDataEexend.appointmenttime, "hhmmss");
      // }
      Data.PRPLINSTRTDATE = formatDate(Data.PRPLINSTRTDATE, "yyyyMMdd");
      Data.PRPLINSTRTIME = formatDate(Data.PRPLINSTRTIME, "hhmmss");
      Data.PRPCALLDATE = formatDate(Data.PRPCALLDATE, "yyyyMMdd");
      Data.PRPWORKDATE = formatDate(Data.PRPWORKDATE, "yyyyMMdd");
      Data.PRPWORKTIME = formatDate(Data.PRPWORKTIME, "hhmm") + '00';
      Data.PRPCAUSA = this.cauinfo[0];
      Data.PRPCAUSASON = this.cauinfo[1];
      Data.Cdh.STANAME = this.prpData.Cdh.STANAME;
      apiBase.DoService(
        Data,
        apiBase.getApiAdress().Reserve.CreatePhoneReserve,
        res => {
          this.addsInfo = res.data.content;
          this.$confirm("是否打印派车单?", "新增成功", {
            confirmButtonText: "打印",
            cancelButtonText: "不打印",
            type: "warning"
          })
            .then(() => {
              this.$refs.prints.open("打印派车单", this.addsInfo.PRPID, null);
            })
            .catch(() => {
              this.$message({
                type: "success",
                message: "新增成功!"
              });
              this.refreshData();
            });
          this.$refs.dialog.close();
        },
        res => {
          this.$message.error(res.data.msg);
        }
      );
    },
    //登记修改
    dataModify() {
      for(var i in this.pickupcardatas){
        if(this.pickupcardatas[i].label == this.pickupcar){
          this.prpData.Cdh.CDHCARID = this.pickupcardatas[i].value;
        }
      }
      console.log(5001);
      console.log(this.prpData.Cdh.STANAME);
      let Data = JSON.parse(JSON.stringify(this.prpData));
      if(Data.PRPFEEDERCATEGORY == null){
        Data.PRPFEEDERCATEGORY = '';
      }
      if(Data.PRPLINID == null){
        Data.PRPLINID = '';
      }
      if(Data.PRPMEMID == null){
        Data.PRPMEMID = '';
      }
      // if(Data.PRPLINID == ''){
      //   Data.PRPLINSTRTDATE = '';
      //   Data.PRPLINSTRTIME = '';
      // }else{
      //   Data.PRPLINSTRTDATE = formatDate(this.regDataEexend.leasetime, "yyyyMMdd");
      //   Data.PRPLINSTRTIME = formatDate(this.regDataEexend.leasetime, "hhmmss");
      // }
      // if(Data.PRPMEMID == ''){
      //   Data.PRPMEMSTRDATE = '';
      //   Data.PRPMENSTRTIME = '';
      // }else{
      //   Data.PRPMEMSTRDATE = formatDate(this.regDataEexend.appointmenttime, "yyyyMMdd");
      //   Data.PRPMENSTRTIME = formatDate(this.regDataEexend.appointmenttime, "hhmmss");
      // }
      // this.prpData.PRPCORPSEADDRESS= this.carryArea;
      Data.PRPLINSTRTDATE = formatDate(Data.PRPLINSTRTDATE, "yyyyMMdd");
      Data.PRPLINSTRTIME = formatDate(Data.PRPLINSTRTIME, "hhmmss");
      Data.PRPCALLDATE = formatDate(Data.PRPCALLDATE, "yyyyMMdd");
      Data.PRPWORKDATE = formatDate(Data.PRPWORKDATE, "yyyyMMdd");
      Data.PRPWORKTIME = formatDate(Data.PRPWORKTIME, "hhmm") + '00';
      Data.PRPCAUSA = this.cauinfo[0];
      Data.PRPCAUSASON = this.cauinfo[1];
      Data.Cdh.STANAME = this.prpData.Cdh.STANAME;
      apiBase.DoService(
        Data,
        apiBase.getApiAdress().Reserve.ModifyPhoneReserve,
        res => {
          this.$refs.dialog.close();
          this.$message({
            type: "success",
            message: "修改成功!"
          });
          this.refreshData();
        }
      );
    },
    //登记详情
    dataInfo(id) {
      let Data = {
        PRPID: id
      };
      apiBase.DoService(
        Data,
        apiBase.getApiAdress().Reserve.DetailPhoneReserve,
        res => {
          this.prpData = res.data.content;
          // this.prpData.PRPLINSTRTDATES = res.data.content.PRPLINSTRTDATE;
          this.prpData.PRPLINSTRTIME = timeStringToDate(res.data.content.PRPLINSTRTIME);
          this.carryArea = this.prpData.PRPCORPSEADDRESS;
          // this.regDataEexend.leasetime = timeStringToDate(
          //   this.prpData.PRPLINSTRTIME,
          //   this.prpData.PRPLINSTRTDATE
          // );
          // this.regDataEexend.appointmenttime = timeStringToDate(
          //   this.prpData.PRPMENSTRTIME,
          //   this.prpData.PRPMEMSTRDATE
          // );
          this.prpData.PRPWORKTIME = timeStringToDate(this.prpData.PRPWORKTIME);
          this.prpData.PRPLINID = this.prpData.PRPLINID;
          ORDER.PRPLINID = this.prpData.PRPLINID;
          this.prpData.PRPLINNAME = this.prpData.PRPLINNAME;
          if (!this.prpData.Cdh) {
            this.cdhcar = ["", ""];
            this.carType = "自送";
          } else {
            this.cdhcartype = this.prpData.Cdh.CARCODNAMEDESC;
            this.carType = this.prpData.Cdh.CARCODNAMEDESC + "/" + this.prpData.Cdh.CARLIC;
            this.pickupcardata(this.cdhcartype);
            this.pickupcar = this.prpData.Cdh.CARLIC;
            this.cdhcar = [
              this.prpData.Cdh.CARCODNAME,
              this.prpData.Cdh.CDHCARID
            ];
           
          console.log(this.carType);
          }
        //  this.getServiceItems(); 

          if (!this.prpData.Psts) {
            this.prpData.Psts = [];
          }
          if (!this.prpData.Cdh) {
            this.prpData.Cdh = {
              CDHCARID: null,
              CDHDRIVER: null
            };
          }
          let psts = res.data.content.Psts;
          for (var i in psts) {
            this.checkedItem.push(psts[i].PSTSITID);
          }
           this.cauinfo = [this.prpData.PRPCAUSA, this.prpData.PRPCAUSASON];
           this.gethallnumber();
        }
      );
    },
    selectAddr() {
      //if(this.selected)
      this.prpData.PRPCORPSEADDRESS = this.prpData.PRPADDID + "";
    },
    //服务项目选择
    ServiceItemsChange(serItems) {
      let pstsList = [];
      for (var i in serItems) {
        var pst = {
          PSTSITID: serItems[i],
          PSTNUMBER: 1
        };
        this.preSitDesc += pstsList.push(pst);
      }
      this.prpData.Psts = pstsList;
    },
    //服务项目选择
    changItem(el, val) {
      var staname = val.SITNAME + "。";
      if (el) {
        this.prpData.PRPDESCRIBE += staname;
      } else {
        this.prpData.PRPDESCRIBE = this.prpData.PRPDESCRIBE.replace(
          staname,
          ""
        );
      }
    },
    //数据重置
    dataRepeat() {
      this.prpWorkDateTime = null;
      this.carryArea = "";
      this.pcrFirst = false;
      this.preFirst = false;
      this.checkedItem = [];
      this.cdhcar = ["自送", "330109X0F1CAR20171227000000018"];
      this.cauinfo = [];
      this.pickupcardatas = [];
      this.cdhcartype = null;
      this.pickupcar = null;
      this.PRPLINID = null;
      this.PRPLINMAN = null;
      this.prpData.PRPWORKTIME = null;
      this.prpData.PRPLINSTRTIME = null,

      Object.assign(this.$data.prpData, this.$options.data().prpData);
      this.prpData.PRPCALLDATE = formatDate(new Date(), "yyyy-MM-dd");
      // this.prpData.PRPLINSTRTDATE = formatDate(new Date(), "yyyy-MM-dd");
      // this.regDataEexend.leasetime = null;
      // this.regDataEexend.appointmenttime = null;
    },
    refreshData() {
      this.$emit("refreshData");
    }
  },
  components: {
    sweetModal,
    printPdf
  },
  watch:{
    cauinfo: function(val) {
      this.REGCAUSA = val[0];
      this.REGCAUSASON = val[1];
    },
    //  "regDataEexend.leasetime": function(val) {
    //   this.prpData.PRPLINSTRTDATE = formatDate(val, "yyyyMMdd");
    //   this.prpData.PRPLINSTRTIME = formatDate(val, "hhmmss");
    // },
    // "regDataEexend.appointmenttime":function(val) {
    //   this.prpData.PRPMEMSTRDATE = formatDate(val, "yyyyMMdd");
    //   this.prpData.PRPMENSTRTIME = formatDate(val, "hhmmss");
    // },
   
  }
};
</script>

